

x = c(1,2,2,3,3,3,4,4,4,4)/2
brks = c(0.25, 0.75, 1.25, 1.75, 2.25)
hist(x, breaks=brks, col="purple", freq=TRUE)
hist(x, breaks=brks, col="magenta", freq=FALSE)

brks = c(0.25, 0.75, 1.25, 1.75, 2.25, 2.75, 3.25, 3.75, 4.25)/2
hist(x,breaks=brks, col="cyan", freq=FALSE)